from ast import main
from config import RagConfig
from openai import OpenAI

from utils import get_b64_image_from_path
from llms import vllm

# VLLM_BASE_URL="https://xiaoai.plus/v1"
# VLLM_MODEL_NAME="gpt-4-vision-preview"
# VLLM_API_KEY="sk-lYp1RcVMaX4uHjcnLasZ75DPNrpXSxx0dJTDxBCKZ1TJKHPi"

from openai import OpenAI

client=vllm()

image_b64 = get_b64_image_from_path('/home/tom/my_learn/my_danwen/0_playgrounds/0_test_data/南瓜.png')

response = client.chat.completions.create(
    model='gpt-4-vision-preview',
    # model=client.models.list().data[0].id,

    messages = [
        {
            "role": "user",
            "content":
                [
                    {
                        "type": "text",
                        "text": "中文描述下图片"
                    },
                    {
                        "type": "image_url",
                        "image_url":{"url": f"data:image/png;base64,{image_b64}"}
                    }
                ]
        }
    ],
    temperature=0.8,
    top_p=0.8)
print(response)



